From: tsteven4 Date: Sun, 3 Mar 2019 17:26:27 +0000 (-0700) Subject: clang-tidy modernize-use-nullptr on gui. X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~8^2~32^2~8 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22Program/%22http:/www.example.com/cgi/%22https:/%22Program?a=commitdiff_plain;h=01e4359d49f1e8b5aead16c9fa9b099665e94a9e;p=gpsbabel.git clang-tidy modernize-use-nullptr on gui. --- diff --git a/gui/formatload.cc b/gui/formatload.cc index 79b7e2636..fc806cf60 100644 --- a/gui/formatload.cc +++ b/gui/formatload.cc @@ -156,7 +156,7 @@ bool FormatLoad::getFormats(QList& formatList) Format format; if (!processFormat(format)) { QMessageBox::information - (0, appName, + (nullptr, appName, QObject::tr("Error processing formats from running process \"gpsbabel -^3\" at line %1").arg(lineList[currentLine_])); } else { formatList << format; diff --git a/gui/gmapdlg.cc b/gui/gmapdlg.cc index aec2fec66..c69177ae5 100644 --- a/gui/gmapdlg.cc +++ b/gui/gmapdlg.cc @@ -250,7 +250,7 @@ void GMapDialog::itemChangedX(QStandardItem* it) else { // Individual items, find the right one. GpxItem* git = static_cast(it->data().value()); - if (git != 0) { + if (git != nullptr) { git->setVisible(show); for (int i=0; iexec(); diff --git a/gui/mainwindow.cc b/gui/mainwindow.cc index 25a4b4d69..3ff7fa4af 100644 --- a/gui/mainwindow.cc +++ b/gui/mainwindow.cc @@ -216,7 +216,7 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent) } if (!babelData_.ignoreVersionMismatch_ && babelVersion_ != VERSION) { - VersionMismatch vm(0, babelVersion_, QString(VERSION)); + VersionMismatch vm(nullptr, babelVersion_, QString(VERSION)); vm.exec(); babelData_.ignoreVersionMismatch_ = vm.neverAgain(); @@ -277,7 +277,7 @@ void MainWindow::createLanguageMenu(void) // Called every time, when a menu entry of the language menu is called void MainWindow::slotLanguageChanged(QAction* action) { - if (0 != action) { + if (nullptr != action) { // load the language dependant on the action content. loadLanguage(action->data().toString()); } @@ -311,7 +311,7 @@ void MainWindow::loadLanguage(const QString& rLanguage) void MainWindow::changeEvent(QEvent* event) { - if (0 != event) { + if (nullptr != event) { switch (event->type()) { // This event is sent if a translator is loaded. case QEvent::LanguageChange: @@ -536,7 +536,7 @@ void MainWindow::browseInputFile() } QStringList userList = - QFileDialog::getOpenFileNames(0, tr("Select one or more input files"), + QFileDialog::getOpenFileNames(nullptr, tr("Select one or more input files"), startFile, filterForFormat(idx)); if (!userList.empty()) { @@ -564,7 +564,7 @@ void MainWindow::browseOutputFile() } QString str = - QFileDialog::getSaveFileName(0, tr("Output File Name"), + QFileDialog::getSaveFileName(nullptr, tr("Output File Name"), startFile, filterForFormat(idx)); if (str.length() != 0) { @@ -627,7 +627,7 @@ QList MainWindow::outputDeviceFormatIndices() void MainWindow::loadFormats() { if (!FormatLoad().getFormats(formatList_)) { - QMessageBox::information(0, QString(appName), + QMessageBox::information(nullptr, QString(appName), tr("Error reading format configuration. " "Check that the backend program \"gpsbabel\" is properly installed " "and is in the current PATH\n\n" @@ -638,7 +638,7 @@ void MainWindow::loadFormats() inputDeviceFormatIndices().empty() || outputFileFormatIndices().empty() || outputDeviceFormatIndices().empty()) { - QMessageBox::information(0, QString(appName), + QMessageBox::information(nullptr, QString(appName), tr("Some file/device formats were not found during initialization. " "Check that the backend program \"gpsbabel\" is properly installed " "and is in the current PATH\n\n" @@ -786,10 +786,10 @@ void MainWindow::inputOptionButtonClicked() int fidx = currentComboFormatIndex(ui_.inputFormatCombo); if (formatList_[fidx].getInputOptionsRef()->empty()) { QMessageBox::information - (0, appName, + (nullptr, appName, tr("There are no input options for format \"%1\"").arg(formatList_[fidx].getDescription())); } else { - OptionsDlg optionDlg(0, + OptionsDlg optionDlg(nullptr, formatList_[fidx].getName(), formatList_[fidx].getInputOptionsRef(), formatList_[fidx].getHtml()); @@ -805,10 +805,10 @@ void MainWindow::outputOptionButtonClicked() int fidx = currentComboFormatIndex(ui_.outputFormatCombo); if (formatList_[fidx].getOutputOptionsRef()->empty()) { QMessageBox::information - (0, appName, + (nullptr, appName, tr("There are no output options for format \"%1\"").arg(formatList_[fidx].getDescription())); } else { - OptionsDlg optionDlg(0, + OptionsDlg optionDlg(nullptr, formatList_[fidx].getName(), formatList_[fidx].getOutputOptionsRef(), formatList_[fidx].getHtml()); @@ -826,7 +826,7 @@ bool MainWindow::isOkToGo() if (!((ui_.xlateWayPtsCk->isChecked() && ui_.xlateWayPtsCk->isEnabled()) || (ui_.xlateRoutesCk->isChecked() && ui_.xlateRoutesCk->isEnabled()) || (ui_.xlateTracksCk->isChecked() && ui_.xlateTracksCk->isEnabled()))) { - QMessageBox::information(0, QString(appName), tr("No valid waypoints/routes/tracks translation specified")); + QMessageBox::information(nullptr, QString(appName), tr("No valid waypoints/routes/tracks translation specified")); return false; } @@ -845,18 +845,18 @@ bool MainWindow::isOkToGo() if ((babelData_.inputType_ == BabelData::fileType_) && (babelData_.inputFileNames_.empty())) { - QMessageBox::information(0, QString(appName), tr("No input file specified")); + QMessageBox::information(nullptr, QString(appName), tr("No input file specified")); return false; } if (babelData_.outputType_ == BabelData::noType_ && babelData_.previewGmap_ == true) { } if (babelData_.outputType_ == BabelData::noType_ && babelData_.previewGmap_ == false) { - QMessageBox::information(0, QString(appName), tr("No valid output specified")); + QMessageBox::information(nullptr, QString(appName), tr("No valid output specified")); return false; } else if (babelData_.outputType_ == BabelData::fileType_ && babelData_.outputFileName_.length() == 0) { - QMessageBox::information(0, QString(appName), tr("No output file specified")); + QMessageBox::information(nullptr, QString(appName), tr("No output file specified")); return false; } return true; @@ -866,10 +866,10 @@ bool MainWindow::isOkToGo() bool MainWindow::runGpsbabel(const QStringList& args, QString& errorString, QString& outputString) { - QProcess* proc = new QProcess(0); + QProcess* proc = new QProcess(nullptr); QString name = "gpsbabel"; proc->start(name, args); - ProcessWaitDialog* waitDlg = new ProcessWaitDialog(0, proc); + ProcessWaitDialog* waitDlg = new ProcessWaitDialog(nullptr, proc); if (proc->state() == QProcess::NotRunning) { errorString = QString(tr("Process \"%1\" did not start")).arg(name); @@ -1031,7 +1031,7 @@ void MainWindow::applyActionX() ui_.outputWindow->appendPlainText(tr("Translation successful")); if (babelData_.previewGmap_) { this->hide(); - GMapDialog dlg(0, tempName, babelData_.debugLevel_ >=1 ? ui_.outputWindow : 0); + GMapDialog dlg(nullptr, tempName, babelData_.debugLevel_ >=1 ? ui_.outputWindow : nullptr); dlg.show(); dlg.exec(); QFile(tempName).remove(); @@ -1054,7 +1054,7 @@ void MainWindow::closeActionX() QDateTime now = QDateTime::currentDateTime(); if ((babelData_.runCount_ == 1) || ((babelData_.runCount_ > 5) && (babelData_.donateSplashed_.daysTo(now) > 30))) { - Donate donate(0); + Donate donate(nullptr); if (babelData_.donateSplashed_.date() == QDate(2010,1,1)) { donate.showNever(false); } @@ -1063,7 +1063,7 @@ void MainWindow::closeActionX() } saveSettings(); delete upgrade; - upgrade = 0; + upgrade = nullptr; qApp->exit(0); } @@ -1172,7 +1172,7 @@ void MainWindow::resetFormatDefaults() //------------------------------------------------------------------------ void MainWindow::moreOptionButtonClicked() { - AdvDlg advDlg(0, babelData_.synthShortNames_, + AdvDlg advDlg(nullptr, babelData_.synthShortNames_, babelData_.previewGmap_, babelData_.debugLevel_); connect(advDlg.formatButton(), SIGNAL(clicked()), this, SLOT(resetFormatDefaults())); @@ -1181,7 +1181,7 @@ void MainWindow::moreOptionButtonClicked() //------------------------------------------------------------------------ void MainWindow::aboutActionX() { - AboutDlg aboutDlg(0, babelVersion_, QString(appName) + QString(" " VERSION), babelData_.installationUuid_); + AboutDlg aboutDlg(nullptr, babelVersion_, QString(appName) + QString(" " VERSION), babelData_.installationUuid_); aboutDlg.setWindowTitle(tr("About %1").arg(appName)); aboutDlg.exec(); } @@ -1197,7 +1197,7 @@ void MainWindow::upgradeCheckActionX() //------------------------------------------------------------------------ void MainWindow::preferencesActionX() { - Preferences preferences(0, formatList_, babelData_); + Preferences preferences(nullptr, formatList_, babelData_); preferences.exec(); // We may have changed the list of displayed formats. Resynchronize. @@ -1213,7 +1213,7 @@ void MainWindow::helpActionX() //------------------------------------------------------------------------ void MainWindow::filtersClicked() { - FilterDialog dlg(0, filterData_); + FilterDialog dlg(nullptr, filterData_); dlg.runDialog(); updateFilterStatus(); } @@ -1326,5 +1326,5 @@ QString MainWindow::getFormatNameForExtension(const QString& ext) } } } - return 0; + return nullptr; } diff --git a/gui/map.cc b/gui/map.cc index d4282274f..ea9c84ec2 100644 --- a/gui/map.cc +++ b/gui/map.cc @@ -92,7 +92,7 @@ Map::Map(QWidget* parent, QString baseFile = QApplication::applicationDirPath() + "/gmapbase.html"; if (!QFile(baseFile).exists()) { - QMessageBox::critical(0, appName, + QMessageBox::critical(nullptr, appName, tr("Missing \"gmapbase.html\" file. Check installation")); } else { QString urlStr = "file:///" + baseFile; @@ -130,7 +130,7 @@ void Map::loadFinishedX(bool f) { this->logTime("Done initial page load"); if (!f) - QMessageBox::critical(0, appName, + QMessageBox::critical(nullptr, appName, tr("Failed to load Google maps base page")); else { QApplication::processEvents(); diff --git a/gui/optionsdlg.cc b/gui/optionsdlg.cc index 86563b4cb..546d54434 100644 --- a/gui/optionsdlg.cc +++ b/gui/optionsdlg.cc @@ -69,11 +69,11 @@ void FileDlgManager::buttonClicked() { QString str; if (isInFile) { - str = QFileDialog::getOpenFileName(0, tr("Select input file"), + str = QFileDialog::getOpenFileName(nullptr, tr("Select input file"), le->text(), "All Files (*.*)"); } else { - str = QFileDialog::getSaveFileName(0, tr("Select output file"), + str = QFileDialog::getSaveFileName(nullptr, tr("Select output file"), le->text(), "All Files (*.*)"); } @@ -106,7 +106,7 @@ OptionsDlg::OptionsDlg(QWidget* parent, const QString& fmtName, QListaddItem(horizontalSpacer); - QWidget* w = 0; + QWidget* w = nullptr; switch (options_[k].getType()) { case FormatOption::OPTstring: { QLineEdit* lineEdit = new QLineEdit(this); @@ -135,7 +135,7 @@ OptionsDlg::OptionsDlg(QWidget* parent, const QString& fmtName, QListsetChecked(options_[k].getSelected()); - w = 0; + w = nullptr; break; case FormatOption::OPTfloat: { diff --git a/gui/serial_unix.cc b/gui/serial_unix.cc index 7e4d421e7..1fb08db30 100644 --- a/gui/serial_unix.cc +++ b/gui/serial_unix.cc @@ -90,7 +90,7 @@ static const char* deviceNames[] = { "/dev/ttyS3", "/dev/ttyUSB0", "/dev/rfcomm0", - 0 + nullptr }; void MainWindow::osLoadDeviceNameCombos(QComboBox* box) diff --git a/gui/upgrade.cc b/gui/upgrade.cc index 79444e790..73909c85f 100644 --- a/gui/upgrade.cc +++ b/gui/upgrade.cc @@ -49,8 +49,8 @@ static const bool testing = false; UpgradeCheck::UpgradeCheck(QWidget* parent, QList& formatList, BabelData& bd) : QObject(parent), - manager_(0), - replyId_(0), + manager_(nullptr), + replyId_(nullptr), upgradeUrl_(QUrl("http://www.gpsbabel.org/upgrade_check.html")), formatList_(formatList), updateStatus_(updateUnknown), @@ -62,11 +62,11 @@ UpgradeCheck::~UpgradeCheck() { if (replyId_) { replyId_->abort(); - replyId_ = 0; + replyId_ = nullptr; } if (manager_) { delete manager_; - manager_ = 0; + manager_ = nullptr; } } @@ -172,18 +172,18 @@ UpgradeCheck::updateStatus UpgradeCheck::getStatus() void UpgradeCheck::httpRequestFinished(QNetworkReply* reply) { - if (reply == 0) { + if (reply == nullptr) { babelData_.upgradeErrors_++; return; } else if (reply != replyId_) { - QMessageBox::information(0, tr("HTTP"), + QMessageBox::information(nullptr, tr("HTTP"), tr("Unexpected reply.")); } else if (reply->error() != QNetworkReply::NoError) { babelData_.upgradeErrors_++; - QMessageBox::information(0, tr("HTTP"), + QMessageBox::information(nullptr, tr("HTTP"), tr("Download failed: %1.") .arg(reply->errorString())); - replyId_ = 0; + replyId_ = nullptr; reply->deleteLater(); return; } @@ -202,7 +202,7 @@ void UpgradeCheck::httpRequestFinished(QNetworkReply* reply) // Change the url for the next update check. // TOODO: kick off another update check. upgradeUrl_ = redirectUrl; - replyId_ = 0; + replyId_ = nullptr; reply->deleteLater(); return; } @@ -214,11 +214,11 @@ void UpgradeCheck::httpRequestFinished(QNetworkReply* reply) } if (statusCode != 200) { QVariant reason = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute); - QMessageBox::information(0, tr("HTTP"), + QMessageBox::information(nullptr, tr("HTTP"), tr("Download failed: %1: %2.") .arg(statusCode.toInt()) .arg(reason.toString())); - replyId_ = 0; + replyId_ = nullptr; reply->deleteLater(); return; } @@ -231,12 +231,12 @@ void UpgradeCheck::httpRequestFinished(QNetworkReply* reply) QString error_text; // This shouldn't ever be seen by a user. if (!document.setContent(oresponse, &error_text, &line)) { - QMessageBox::critical(0, tr("Error"), + QMessageBox::critical(nullptr, tr("Error"), tr("Invalid return data at line %1: %2.") .arg(line) .arg(error_text)); babelData_.upgradeErrors_++; - replyId_ = 0; + replyId_ = nullptr; reply->deleteLater(); return; } @@ -312,6 +312,6 @@ void UpgradeCheck::httpRequestFinished(QNetworkReply* reply) for (int i = 0; i < formatList_.size(); i++) { formatList_[i].zeroUseCounts(); } - replyId_ = 0; + replyId_ = nullptr; reply->deleteLater(); }